Skip to content

Skip lead_time=0h for ECMWF max/min step_type variables#492

Merged
aldenks merged 4 commits intomainfrom
claude/fix-ecmwf-index-error-iEFcC
Mar 6, 2026
Merged

Skip lead_time=0h for ECMWF max/min step_type variables#492
aldenks merged 4 commits intomainfrom
claude/fix-ecmwf-index-error-iEFcC

Conversation

@aldenks
Copy link
Member

@aldenks aldenks commented Mar 6, 2026

Summary

This PR fixes handling of ECMWF variables with step_type="max" or step_type="min" by skipping lead_time=0h during source file coordinate generation, since these variables have no value at initialization time.

Key Changes

  • New utility function has_hour_0_values() in ecmwf_utils.py to determine if a variable has a value at lead_time=0h

    • Returns False for max/min step_type variables (no prior post-processing step at t=0)
    • Returns True for avg/accum variables (include 0h accumulation in GRIB)
    • Respects optional hour_0_values_override in variable internal attributes
  • Updated region job to skip lead_time=0h when any variable in a group lacks hour 0 values

    • Prevents attempting to read non-existent data at initialization time
    • Reduces expected source file coordinates accordingly (e.g., 2×2×11 instead of 2×2×12)
  • Enhanced integration test to validate variables across multiple lead times

    • Tests both lead_time=0h and lead_time=3h to catch format changes
    • Uses recent dates instead of hardcoded future dates
    • Iterates through generated source coordinates instead of manually constructing them

Implementation Details

The fix ensures that when a data variable group contains any max/min step_type variable, the entire group skips lead_time=0h during coordinate generation, preventing downstream errors when attempting to read unavailable data from ECMWF files.

https://claude.ai/code/session_01LBZoe7ccmmgZxdKD8uHhZr

claude added 4 commits March 6, 2026 13:10
…n job

10fg (wind gust) is a max-window variable absent from the GRIB index at
lead_time=0h since there is no prior post-processing step at initialization
time. The operational update was generating source file coords for all lead
times including 0h, causing a KeyError when looking up '10fg' in the index.

Fix by adding has_hour_0_values() to ecmwf_utils following the same pattern
as noaa_utils, and filtering lead_time=0h coords in generate_source_file_coords
for any variable group where not all variables have hour 0 values.

Update the slow integration test to use a dynamic recent init_time (instead of
hardcoded 2026-01-01) and test via generate_source_file_coords over lead_times
[0h, 3h] so it would catch this class of bug in the future.

https://claude.ai/code/session_01LBZoe7ccmmgZxdKD8uHhZr
- source_groups now groups by (date_available, has_hour_0_values) so all
  variables in a group share the same hour-0 behaviour, allowing
  generate_source_file_coords to use item() for a clean single-value check
- Add tests/ecmwf/test_ecmwf_utils.py with parametrized unit tests for
  has_hour_0_values covering all step_types and the override mechanism

https://claude.ai/code/session_01LBZoe7ccmmgZxdKD8uHhZr
@aldenks aldenks merged commit 2f29a1b into main Mar 6, 2026
5 checks passed
@aldenks aldenks deleted the claude/fix-ecmwf-index-error-iEFcC branch March 6, 2026 16:14
@aldenks aldenks linked an issue Mar 6, 2026 that may be closed by this pull request
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add variables to ECMWF IFS ENS

2 participants